package de.tg.handball.tasks;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.view.View;

public class LoadAsyncWithBarTask extends AsyncTask<String, Object, String[]> {

	ProgressDialog bar = null;
	Runnable run = null;
	View startView = null;
	Intent dest = null;

	public LoadAsyncWithBarTask(View startView, Intent dest, ProgressDialog bar, Runnable run ) {
		this.bar = bar;
		this.run = run;
		this.startView = startView;
		this.dest = dest;
	}

	@Override
	protected void onPreExecute() {
		super.onPreExecute();
	}

	@Override
	protected void onPostExecute(String[] result) {
		bar.cancel();
		if(dest != null)
			startView.getContext().startActivity(dest);
		super.onPostExecute(result);
	}

	@Override
	protected String[] doInBackground(String... params) {
		if(run!= null)
			run.run();
		return null;
	}

}
